﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="order_msg.aspx.cs" Inherits="SF.Ucenter.admin.goods.orders.order_msg" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>查看订单</title>
    <link href="../../../scripts/artdialog/ui-dialog.css" rel="stylesheet" type="text/css" />
    <link href="../../skin/default/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" charset="utf-8" src="../../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../../scripts/jquery/Validform_v5.3.2_min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../../scripts/artdialog/dialog-plus-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/laymain.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/common.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/LodopFuncs.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#btnPrint").click(function () { OrderPrint(); });                //打印订单
            $("#btnPrintExpress").click(function () { OrderPrintExpress(); });  //打印运单（针对aojieer）
            $("#btnEditName").click(function () { EditOrderName(); });          //修改 快递名称
            $("#btnEditNum").click(function () { EditOrderNum(); });            //修改 物流单号
        });
        //打印订单
        function OrderPrint() {
            var winDialog = top.dialog({
                title: '打印订单',
                url: '/admin/dialog/dialog_print.aspx?order_no=' + $("#spanOrderNo").attr("nums"),
                width: 850
            }).showModal();
        }

        //修改 快递名称
        function EditOrderName() {
            var winDialog = top.dialog({
                title: '快递名称',
                content: '<textarea id="txtOrderName" name="txtOrderName" rows="2" cols="20" class="input">' + $("#divName").html() + '</textarea>',
                okValue: '确定',
                ok: function () {
                    var remark = $("#txtOrderName", parent.document).val();
                    if (remark == "") {
                        top.dialog({
                            title: '提示',
                            content: '对不起，请输入快递名称！',
                            okValue: '确定',
                            ok: function () { }
                        }).showModal(winDialog);
                        return false;
                    }
                    var postData = { "order_no": $("#spanOrderNo").attr("nums"), "edit_type": "edit_order_express_name", "remark": remark };
                    //发送AJAX请求
                    sendAjaxUrl(winDialog, postData, "../../../tools/goods_ajax.ashx?action=edit_order_status");
                    return false;
                },
                cancelValue: '取消',
                cancel: function () { }
            }).showModal();
        }

        //修改 物流单号
        function EditOrderNum() {
            var winDialog = top.dialog({
                title: '物流单号',
                content: '<textarea id="txtOrderNum" name="txtOrderNum" rows="2" cols="20" class="input">' + $("#divNum").html() + '</textarea>',
                okValue: '确定',
                ok: function () {
                    var remark = $("#txtOrderNum", parent.document).val();
                    if (remark == "") {
                        top.dialog({
                            title: '提示',
                            content: '对不起，请输入物流单号！',
                            okValue: '确定',
                            ok: function () { }
                        }).showModal(winDialog);
                        return false;
                    }
                    var postData = { "order_no": $("#spanOrderNo").attr("nums"), "edit_type": "edit_order_express_num", "remark": remark };
                    //发送AJAX请求
                    sendAjaxUrl(winDialog, postData, "../../../tools/goods_ajax.ashx?action=edit_order_status");
                    return false;
                },
                cancelValue: '取消',
                cancel: function () { }
            }).showModal();
        }


        //发送AJAX请求
        function sendAjaxUrl(winObj, postData, sendUrl) {
            $.ajax({
                type: "post",
                url: sendUrl,
                data: postData,
                dataType: "json",
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    top.dialog({
                        title: '提示',
                        content: '尝试发送失败，错误信息：' + errorThrown,
                        okValue: '确定',
                        ok: function () { }
                    }).showModal(winObj);
                },
                success: function (data, textStatus) {
                    if (data.status == 1) {
                        winObj.close().remove();
                        var d = dialog({ content: data.msg }).show();
                        setTimeout(function () {
                            d.close().remove();
                            location.reload(); //刷新页面
                        }, 2000);
                    } else {
                        top.dialog({
                            title: '提示',
                            content: '错误提示：' + data.msg,
                            okValue: '确定',
                            ok: function () { }
                        }).showModal(winObj);
                    }
                }
            });
        }

        //打印运单 （针对aojieer）
        function OrderPrintExpress() {
            var text = $("#addressText").text();
            var pars = text.split("_");
            var ids = pars[0].split(",");
            var r = true;
            if (parseInt(ids[1]) > 1) {
                r = parent.confirm("此订单已打印过，是否需要再次打印？");
            }
            if (r == true) {
                var ads = pars[1].split(",");
                var goods = pars[2].substring(0, pars[2].length - 1).split(",");
                LODOP = getLodop();
                LODOP.PRINT_INITA(0, 0, 1186, 600, "");
                LODOP.SET_PRINT_STYLE("FontColor", "#0000FF");
                LODOP.ADD_PRINT_TEXT(84, 28, 100, 20, "奥婕儿");
                LODOP.ADD_PRINT_TEXT(83, 199, 100, 20, "028-86274557");
                LODOP.ADD_PRINT_TEXT(135, 26, 61, 20, "四川");
                LODOP.ADD_PRINT_TEXT(136, 119, 61, 20, "成都");
                LODOP.ADD_PRINT_TEXT(137, 217, 61, 20, "高新");
                LODOP.ADD_PRINT_TEXT(84, 398, 100, 20, ads[0]);
                LODOP.ADD_PRINT_TEXT(84, 573, 100, 20, ads[1]);
                LODOP.ADD_PRINT_TEXT(160, 346, 328, 54, ads[2]);
                var y = 160;
                for (var i = 0; i < goods.length; i++) {
                    var temp = goods[i].split("|");
                    LODOP.ADD_PRINT_TEXT((y + i * 16), 1, 268, 24, temp[0] + "  数量：" + temp[1]);
                }
                var a = LODOP.PRINTA();
                if (a == false) {
                    location.reload();
                } else {
                    $.get("../../../tools/goods_ajax.ashx", { "action": "upadte_express", "id": ids[0] }, function (result) {
                        if (result == "True") {
                            parent.jsprint("打印成功！");
                            location.href = "order_list.aspx.aspx";
                        } else {
                            parent.jsprint("网络繁忙，请稍后再试！");
                            location.reload();
                        }
                    });
                }
            }
        }

    </script>
</head>
<body class="mainbody">
    <form id="form1" runat="server">
    <!--导航栏-->
    <div class="location">
      <a href="order_list.aspx" class="back"><i></i><span>返回列表页</span></a>
      <a href="../../First.aspx" class="home"><i></i><span>首页</span></a>
      <i class="arrow"></i>
      <a href="order_list.aspx"><span>订单管理</span></a>
      <i class="arrow"></i>
      <span>订单详细</span>
    </div>
    <div class="line10"></div>
    <!--/导航栏-->

    <!--内容-->
    <div id="floatHead" class="content-tab-wrap">
      <div class="content-tab">
        <div class="content-tab-ul-wrap">
          <ul>
            <li><a class="selected" href="javascript:;">订单详细信息</a></li>
          </ul>
        </div>
      </div>
    </div>

    <div class="tab-content">
    <asp:Label ID="addressText" runat="server" Text="" style="display:none;"></asp:Label>
      <dl>
        <dd style="margin-left:50px;text-align:center;">
          <div class="order-flow" style="width:560px">
            <%if (model.id >0)
              { %>
            <div class="order-flow-left">
              <a class="order-flow-input">生成</a>
              <span><p class="name">订单已生成</p><p><%=model.addTime%></p></span>
            </div>
            <%if (model.isPay == 1)
              { %>
            <div class="order-flow-wait">
              <a class="order-flow-input">付款</a>
              <span><p class="name">等待付款</p></span>
            </div>
            <%}
              else if (model.isPay == 2)
              { %>
            <div class="order-flow-arrive">
              <a class="order-flow-input">付款</a>
              <span><p class="name">已付款</p><p><%=model.payTime%></p></span>
            </div>
            <%} %>
            <%if (model.isExpress == 1)
              { %>
            <div class="order-flow-wait">
              <a class="order-flow-input">发货</a>
              <span><p class="name">等待发货</p></span>
            </div>
            <%}
              else if (model.isExpress > 1)
              { %>
            <div class="order-flow-arrive">
              <a class="order-flow-input">发货</a>
              <span><p class="name">已发货</p><p><%=model.expressTime%></p></span>
             </div>
             <%} %>
             <%if (model.isComDone == 1)
               { %>
             <div class="order-flow-right-arrive">
               <a class="order-flow-input">完成</a>
               <span><p class="name">订单完成</p><p><%=model.comDoneTime%></p></span>
             </div>
             <%}
               else
               { %>
             <div class="order-flow-right-wait">
               <a class="order-flow-input">完成</a>
               <span><p class="name">等待结算</p></span>
             </div>
             <%} }%>
          </div>
        </dd>
      </dl>
      <dl>
        <dt>订单号</dt>
        <dd><span id="spanOrderNo" nums="<%=model.id %>"><%=model.orderNum %></span></dd>
      </dl>
      <asp:Repeater ID="rptList" runat="server">
      <HeaderTemplate>
      <dl>
        <dt>商品列表</dt>
        <dd>
          <div class="table-container">
            <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="100%">
            <thead>
              <tr>
                <th style="text-align:left;">商品信息</th>
                <th width="8%">单价</th>
                <th width="8%">数量</th>
                <th width="12%">金额合计</th>
              </tr>
            </thead>
            <tbody>
            </HeaderTemplate>
            <ItemTemplate>
              <tr class="td_c">
                <td style="text-align:left;white-space:inherit;word-break:break-all;line-height:20px;">
                  <%#getGoodsMsg(Eval("goodsNum").ToString())%>
                </td>
                <td><%#Eval("price")%></td>
                <td><%#Eval("numbers")%></td>
                <td><%#Eval("totalMoney")%></td>
              </tr>
              </ItemTemplate>
              <FooterTemplate>
            </tbody>
            </table>
          </div>
        </dd>
      </dl>
      </FooterTemplate>
      </asp:Repeater>
      <dl>
        <dt>收货信息</dt>
        <dd>
          <div class="table-container">
            <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="100%">
            <tr>
              <th width="20%">收件人</th>
              <td>
                <div class="position">
                  <span id="spanAcceptName"><%= (model.addressText!=""?(model.addressText).Split(',')[0]:"") %></span>
                </div>
              </td>
            </tr>
            <tr>
              <th>收货地址</th>
              <td><span id="spanArea"><%= (model.addressText!=""?(model.addressText).Split(',')[2]:"") %></span></td>
                  <input id="btnEditAcceptAddress" runat="server" visible="false" type="button" class="ibtn" value="修改" />
            </tr>
            <tr>
              <th>手机</th>
              <td><span id="spanMobile"><%= (model.addressText!=""?(model.addressText).Split(',')[1]:"") %></span></td>
            </tr>
            </table>
          </div>
        </dd>
      </dl>
      <dl id="dlUserInfo" runat="server" visible="false">
        <dt>客户信息</dt>
        <dd>
          <div class="table-container">
            <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="100%">
            <tr>
              <th width="20%">客户编号</th>
              <td><asp:Label ID="lbUserNum" runat="server" /></td>
            </tr>
            <tr>
              <th>微信昵称</th>
              <td><asp:Label ID="lbUserName" runat="server" /></td>
            </tr>
            </table>
          </div>
        </dd>
      </dl>
      <dl>
        <dt>支付配送</dt>
        <dd>
          <div class="table-container">
            <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="100%">
            <tr>
              <th width="20%">支付方式</th>
              <td><%= (model.payWay==1?"微支付":"其它方式") %></td>
            </tr>
            <tr>
              <th>配送方式</th>
              <td>
                <div class="position">
                    <div id="divName"><%=model.expressName %></div>
                    <input id="btnEditName" runat="server" type="button" class="ibtn" value="修改" />
                </div>
              </td>
            </tr>
            <%--<tr>
              <th valign="top">订单备注</th>
              <td>
                <div class="position">
                  <div id="divRemark"><%=model.remark %></div>
                  <input id="btnEditRemark" runat="server" visible="false" type="button" class="ibtn" value="修改" />
                </div>
              </td>
            </tr>--%>
            <tr>
              <th>物流单号</th>
              <td>
                <div class="position">
                    <div id="divNum"><%=model.expressNum%></div>
                    <input id="btnEditNum" runat="server" type="button" class="ibtn" value="修改" />
                </div>
              </td>
            </tr>
            </table>
          </div>
        </dd>
      </dl>
      <dl>
        <dt>订单统计</dt>
        <dd>
          <div class="table-container">
            <table border="0" cellspacing="0" cellpadding="0" class="border-table" width="100%">
            <tr>
              <th width="20%">商品总金额</th>
              <td>
                <div class="position">
                  <span id="spanRealAmountValue"><%=model.totalMoney %></span> 元
                  <input id="btnEditRealAmount" runat="server" visible="false" type="button" class="ibtn" value="调价" />
                </div>
              </td>
            </tr>
            <%--<tr>
              <th>配送费用</th>
              <td>
                <div class="position">
                  <span id="spanExpressFeeValue"><%=model.express_fee %></span> 元
                  <input id="btnEditExpressFee" runat="server" visible="false" type="button" class="ibtn" value="调价" />
                </div>
              </td>
            </tr>--%>
            <tr>
              <th>订单总金额</th>
              <td><%=model.totalMoney %> 元</td>
            </tr>
            </table>
          </div>
        </dd>
      </dl>
    </div>
    <!--/内容-->


    <!--工具栏-->
    <div class="page-footer">
      <div class="btn-wrap">
        <input id="btnConfirm" runat="server" visible="false" type="button" value="确认订单" class="btn" />
        <input id="btnPayment" runat="server" visible="false" type="button" value="确认付款" class="btn" />
        <input id="btnExpress" runat="server" visible="false" type="button" value="确认发货" class="btn" />
        <input id="btnComplete" runat="server" visible="false" type="button" value="完成订单" class="btn" />
        <input id="btnCancel" runat="server" visible="false" type="button" value="取消订单" class="btn green" />
        <input id="btnInvalid" runat="server" visible="false" type="button" value="作废订单" class="btn green" />
        <input id="btnPrint" runat="server" type="button" value="打印订单" class="btn violet" />
        <input id="btnPrintExpress" runat="server" style="display:<%=dis %>;" type="button" value="打印运单" class="btn green" />
        <input id="btnReturn" runat="server" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />
      </div>
    </div>
    <!--/工具栏-->

    </form>
    </body>
</html>
